package com.aliyun.oss.UserService.impl;

import com.aliyun.oss.UserMapper.DishFlavorMapper;
import com.aliyun.oss.UserMapper.DishMapper;
import com.aliyun.oss.UserService.DishService;
import com.aliyun.oss.pojo.Entity.Food;
import com.aliyun.oss.pojo.Vo.UserDish;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("userDishServiceImpl")
public class DishServiceImpl extends ServiceImpl<DishMapper, Food> implements DishService {
    @Autowired
    DishFlavorMapper dishFlavorMapper;
    @Override
    public List<UserDish> list(Long categoryId) {
//        根据分类id查找菜品，同时根据每个菜品id查找菜品的口味
        List<UserDish> list = baseMapper.list(categoryId);
        for (UserDish userDish : list) {
            userDish.setFlavors(dishFlavorMapper.list(userDish.getId()));
        }
        return list;
    }
}
